#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
const int N=101000;
ll T,n,m,l,v;
ll d,v0,a,p[N],ans,dep,ss[N],wz,anss,ma;
ld L[N],R[N];
ld x,jd0,cs;
bool vis[N],viss[N];
vector<ll> q;
inline ll read(){
	ll sum=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-')f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		sum=sum*10+(ll)(ch)-'0';
		ch=getchar();
	}
	return sum*f;
}
struct qjj1{
	ld L,R;
}qj1[N];
struct qjj2{
	ld L,R;
}qj2[N];
bool cmp1(qjj1 a,qjj1 b){
	if(a.L!=b.L)return a.L<b.L;
	return a.R<b.R;
}
bool cmp2(qjj2 a,qjj2 b){
	if(a.L!=b.L)return a.L<b.L;
	return a.R<b.R;
}
int main(){
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	T=read();
	while(T--){
		for(int i=1;i<=n;i++){
			qj1[i].L=0,qj1[i].R=0,vis[i]=0,ss[i]=0;
		}
		ans=anss=0;
		n=read();
		m=read();
		l=read();
		v=read();
		for(int i=1;i<=n;i++){
			d=read();
			v0=read();
			a=read();
			if(a>0){
				if(v0>v){
					qj1[i].L=d-0.01;
					qj1[i].R=l+0.01;
				}
				else if(v0==v){
					qj1[i].L=-1;
					qj1[i].R=-1;
				}
				else {
					x=d+(v*v-v0*v0)*1.0/(2*a);
					if(x<=l){
						qj1[i].L=x;
						qj1[i].R=l+0.01;
					}
					else {
						qj1[i].L=-1;
						qj1[i].R=-1;
					}
				}
			}
			else if(a==0){
				if(v0>v){
					qj1[i].L=d-0.01;
					qj1[i].R=l+0.01;
				}
				else if(v0==v){
					qj1[i].L=-1;
					qj1[i].R=-1;
				}
				else {
					qj1[i].L=-1;
					qj1[i].R=-1;
				}
			}
			else {
				
				if(v0<=v){
					qj1[i].L=-1;
					qj1[i].R=-1;
				}
				else {
					x=d+(v*v-v0*v0)*1.0/(2*a);
					if(x<=l){
						qj1[i].L=d-0.01;
						qj1[i].R=x;
					}
					else {
						qj1[i].L=d-0.01;
						qj1[i].R=l+0.01;
					}
				}
			}
		}
		//cout<<qj1[2].L<<' '<<qj1[2].R<<endl;
		sort(qj1+1,qj1+n+1,cmp1);
		for(int i=1;i<=m;i++){
			p[i]=read();
			for(int j=1;j<=n;j++){
				if(p[i]>qj1[j].L&&p[i]<qj1[j].R){
					vis[j]=1;
					viss[i]=1;
					//cout<<j<<endl;
				}
			}
		}
		for(int i=1;i<=n;i++){
			if(vis[i]==1){
				qj2[i].L=qj1[i].L;
				qj2[i].R=qj1[i].R;
				ans++;
			}
		}
		cout<<ans<<' ';
		ll gs=0;
		for(int i=1;i<=m;i++){
			if(viss[i]==1){
				gs++;
			}
		}
		sort(qj2+1,qj2+n+1,cmp2);
		sort(p+1,p+m+1);
		dep=1;
		for(int i=1;i<=ans;i++){
			q.clear();
			for(int j=m;j>=1;j--){
				if(p[j]>qj2[i].L&&p[j]<qj2[i].R&&p[j]){
					q.push_back(p[j]);
				}
			}
			ma=-1;
			for(int j=0;j<q.size();j++){
				ss[j]=1;
				for(int k=i+1;k<=ans;k++){
					if(q[j]>=qj2[k].L)ss[j]++;
				}
				ma=max(ma,ss[j]);
			}
			wz=-1;
			for(int j=0;j<q.size();j++){
				if(ss[j]==ma){
					anss++;
					for(int k=i+1;k<=ans;k++){
						if(q[j]>=qj2[k].L)wz=k;
					}
					if(wz!=-1)i=wz+1;
					break;
				}
			}
			//if(wz==-1)break;
		}
		cout<<gs-ans+m-gs+1<<endl;
	}
	return 0;
}
/*duo ce yao qing kong*/
